<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'base.item.class.php');

class CoreBranchDepartmentBase extends BaseItemBase {
	var $table = 'pp_core_branches';
	var $prefix = 'branches_';
	
	var $table_department = 'pp_core_departments';
	var $prefix_department = 'departments_';
	
	//constructor
	function CoreBranchDepartmentBase() {
		parent::BaseItemBase();
	}
	
	//methods
	function getDepartments($items_id, $check = 0) {
		$query_str = "";
		if( $check == -1 ) {
			//
		} else {
			$query_str .= " and b.branches_status = 1";
		}
		$query = "select d.* from pp_core_branches b, pp_core_departments d where b.branches_id = '" . (int)$items_id . "' " 
				. " and d.branches_id = b.branches_id and 1";
		
		return $this->adb->getRows($query);
	}
	
	function getDepartmentsTotal($items_id, $check = 0, $level = 1) {
		$query_str = "";
		if( $check == -1 ) {
			//
		} else {
			$query_str = " and b.branches_status = 1";
		}
		
		$query = "select count(*) as count from pp_core_branches b, pp_core_departments d " 
				. " where b.branches_id = '" . (int)$items_id . "' and d.branches_id = b.branches_id and 1";
		
		return $this->adb->getCount($query);
	}
	
	function updateItemDepartment($departments_id, $data_array, $items_id) {
		
	}
	
	//private
}
//
?>